package com.informix.stream.api.records;


import com.informix.stream.api.IfmxStreamOperationRecord;
import com.informix.stream.api.IfmxStreamRecord;
import com.informix.stream.common.enums.IfmxStreamRecordType;
import com.informix.stream.api.records.IfxCDCBeginTransactionRecord;

import java.util.List;

public class IfmxStreamTransactionRecord
        implements IfmxStreamRecord {
    private final IfxCDCBeginTransactionRecord beginRecord;
    private final IfmxStreamRecord closingRecord;
    private final List<IfmxStreamOperationRecord> records;

    public IfmxStreamTransactionRecord(IfxCDCBeginTransactionRecord beginRecord, IfmxStreamRecord closingRecord, List<IfmxStreamOperationRecord> records) {
        this.beginRecord = beginRecord;
        this.closingRecord = closingRecord;
        this.records = records;
    }


    public IfmxStreamRecordType getType() {
        return IfmxStreamRecordType.TRANSACTION_GROUP;
    }


    public boolean hasOperationData() {
        return false;
    }


    public String getLabel() {
        return this.beginRecord.getLabel();
    }


    public int getTransactionId() {
        return this.beginRecord.getTransactionId();
    }


    public long getSequenceId() {
        return this.beginRecord.getSequenceId();
    }

    public IfxCDCBeginTransactionRecord getBeginRecord() {
        return this.beginRecord;
    }

    public IfmxStreamRecord getEndRecord() {
        return this.closingRecord;
    }

    public List<IfmxStreamOperationRecord> getOperationRecords() {
        return this.records;
    }


    public String toString() {
        return this.beginRecord.toString() + "\n" + getOperationRecords() + "\n" + this.closingRecord.toString();
    }
}


